package Test;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class tpcc1  extends JPanel{

	private static final long serialVersionUID = 1L;
	public JTextField Database;
	public JTextField Driver;
	public JTextField Conn;
	public JTextField User;
	public JTextField Password;
	public JTextField Warehouses;
	public JTextField LoadWorkers;
	public JTextField Terminals;
	public JTextField runTxnsPerTerminal;
	public JTextField runMins;
	public JTextField limitTxnsPerMin;
	public JComboBox<String> terminalWarehouseFixed;
	public JTextField newOrderWeight;
	public JTextField paymentWeight;
	public JTextField orderStatusWeight;
	public JTextField deliveryWeight;
	public JTextField stockLevelWeight;
	public JTextField resultDirectory;
	
	public JButton Init;
	public JButton Cancel;
	private JButton more;
	public tpcc1(){
		//初始化组件
		Dimension size = new Dimension(185, 28);
		Database = new JTextField("db");
		Driver = new JTextField("org.hhdbsql.Driver");
		Driver = new JTextField("org.hhdbsql.Driver");
		Conn = new JTextField("jdbc:hhdbsql://localhost:1432/hhdb");
		User = new JTextField("db");
		Password = new JTextField("123456");
		Warehouses = new JTextField("1");
		LoadWorkers = new JTextField("4");
		Terminals = new JTextField("1");
		runTxnsPerTerminal = new JTextField("0");
		runMins = new JTextField("1");
		limitTxnsPerMin = new JTextField("0");
		terminalWarehouseFixed = new JComboBox<String>();
		terminalWarehouseFixed.addItem("true");
		terminalWarehouseFixed.addItem("false");
		terminalWarehouseFixed.setPreferredSize(size);
		terminalWarehouseFixed.setSelectedIndex(0);
		newOrderWeight = new JTextField("45");
		newOrderWeight.setPreferredSize(size);
		paymentWeight = new JTextField("43");
		paymentWeight.setPreferredSize(size);
		orderStatusWeight = new JTextField("4");
		orderStatusWeight.setPreferredSize(size);
		resultDirectory = new JTextField("my_result_%tY-%tm-%td_%tH%tM%tS");
		resultDirectory.setPreferredSize(size);
		Init = new JButton("初始化");
		Cancel = new JButton("返回");
		more = new JButton("...");
	}
	public JPanel init() {
		JPanel jp = new JPanel();
		JPanel jpnorth = new JPanel(new GridLayout(5, 1));
		jpnorth.setSize(400, 450);
		JPanel jpnorth1 = new JPanel(new GridLayout(13, 1));
		

		Dimension size = new Dimension(185, 28);
		Insets left = new Insets(5, 5, 0, 0);
		Insets right = new Insets(5, 5, 0, 40);
		JPanel jp1 = new JPanel(new GridBagLayout());
		Database = new JTextField("db");
		Database.setPreferredSize(size);
		jp1.add(new JLabel("Database:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp1.add(Database, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp2 = new JPanel(new GridBagLayout());
		Driver = new JTextField("org.hhdbsql.Driver");
		Driver.setPreferredSize(size);
		jp2.add(new JLabel("Driver:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp2.add(Driver, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp3 = new JPanel(new GridBagLayout());
		Conn = new JTextField("jdbc:hhdbsql://localhost:1432/hhdb");
		Conn.setPreferredSize(size);
		jp3.add(new JLabel("Conn:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp3.add(Conn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp4 = new JPanel(new GridBagLayout());
		User = new JTextField("db");
		User.setPreferredSize(size);
		jp4.add(new JLabel("User:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp4.add(User, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp5 = new JPanel(new GridBagLayout());
		Password = new JTextField("123456");
		Password.setPreferredSize(size);
		jp5.add(new JLabel("Password:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp5.add(Password, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp6 = new JPanel(new GridBagLayout());
		Warehouses = new JTextField("1");
		Warehouses.setPreferredSize(size);
		jp6.add(new JLabel("Warehouses:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp6.add(Warehouses, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp7 = new JPanel(new GridBagLayout());
		LoadWorkers = new JTextField("4");
		LoadWorkers.setPreferredSize(size);
		jp7.add(new JLabel("Warehouses:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp7.add(LoadWorkers, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp8 = new JPanel(new GridBagLayout());
		Terminals = new JTextField("1");
		Terminals.setPreferredSize(size);
		jp8.add(new JLabel("Terminals:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp8.add(Terminals, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		JPanel jp9 = new JPanel(new GridBagLayout());
		runTxnsPerTerminal = new JTextField("0");
		runTxnsPerTerminal.setPreferredSize(size);
		jp9.add(new JLabel("RunTxnsPerTerminal:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp9.add(runTxnsPerTerminal, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp10 = new JPanel(new GridBagLayout());
		runMins = new JTextField("1");
		runMins.setPreferredSize(size);
		jp10.add(new JLabel("RunMins:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp10.add(runMins, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp11 = new JPanel(new GridBagLayout());
		limitTxnsPerMin = new JTextField("0");
		limitTxnsPerMin.setPreferredSize(size);
		jp11.add(new JLabel("LimitTxnsPerMin:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp11.add(limitTxnsPerMin, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp12 = new JPanel(new GridBagLayout());
		terminalWarehouseFixed = new JComboBox<String>();
		terminalWarehouseFixed.addItem("true");
		terminalWarehouseFixed.addItem("false");
		terminalWarehouseFixed.setPreferredSize(size);
		terminalWarehouseFixed.setSelectedIndex(0);
		jp12.add(new JLabel("TerminalWarehouseFixed:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp12.add(terminalWarehouseFixed, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp13 = new JPanel(new GridBagLayout());
		newOrderWeight = new JTextField("45");
		newOrderWeight.setPreferredSize(size);
		jp13.add(new JLabel("NewOrderWeight:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp13.add(newOrderWeight, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp14 = new JPanel(new GridBagLayout());
		paymentWeight = new JTextField("43");
		paymentWeight.setPreferredSize(size);
		jp14.add(new JLabel("PaymentWeight:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp14.add(paymentWeight, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp15 = new JPanel(new GridBagLayout());
		orderStatusWeight = new JTextField("4");
		orderStatusWeight.setPreferredSize(size);
		jp15.add(new JLabel("OrderStatusWeight:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp15.add(orderStatusWeight, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp16 = new JPanel(new GridBagLayout());
		deliveryWeight = new JTextField("4");
		deliveryWeight.setPreferredSize(size);
		jp16.add(new JLabel("DeliveryWeight:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp16.add(deliveryWeight, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp17 = new JPanel(new GridBagLayout());
		stockLevelWeight = new JTextField("4");
		stockLevelWeight.setPreferredSize(size);
		jp17.add(new JLabel("StockLevelWeight:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp17.add(stockLevelWeight, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));
		
		JPanel jp18 = new JPanel(new GridBagLayout());
		resultDirectory = new JTextField("my_result_%tY-%tm-%td_%tH%tM%tS");
		resultDirectory.setPreferredSize(size);
		jp18.add(new JLabel("ResultDirectory:"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST,GridBagConstraints.NONE, left, 0, 0));
		jp18.add(resultDirectory, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, right, 0, 0));

		jpnorth.add(jp1);
		jpnorth.add(jp2);
		jpnorth.add(jp3);
		jpnorth.add(jp4);
		jpnorth.add(jp5);
		jpnorth1.add(jp6);
		jpnorth1.add(jp7);
		jpnorth1.add(jp8);
		jpnorth1.add(jp9);
		jpnorth1.add(jp10);
		jpnorth1.add(jp11);
		jpnorth1.add(jp12);
		jpnorth1.add(jp13);
		jpnorth1.add(jp14);
		jpnorth1.add(jp15);
		jpnorth1.add(jp16);
		jpnorth1.add(jp17);
		jpnorth1.add(jp18);
		JPanel jpsouth = new JPanel();
		jpsouth.setSize(400, 30);
		Init = new JButton("初始化");
		Cancel = new JButton("返回");
		jpsouth.add(Init);
		jpsouth.add(Cancel);
		jp.add(jpnorth);
		jp.add(jpnorth1);
		jp.add(jpsouth);
		
		//jpnorth1.setVisible(false);
		return jp;

	}

	public static void main(String[] args) {
		JFrame jf = new JFrame("新建一个窗体");
		jf.setLocationRelativeTo(null);
		jf.setSize(400, 700);
		ImageIcon icon = new ImageIcon("etc/icon/manage.png");
		jf.setIconImage(icon.getImage());
		JPanel jp = new tpcc1().init();
		jf.add(jp);
		jf.setVisible(true);
		
	}
}
